<template>
  <div ref="main"></div>
</template>
<script setup>
import * as echarts from 'echarts'
import { onMounted, ref, watch } from 'vue';
const main = ref(null)
const props = defineProps({
  width: {
    type: String
  },
  height: {
    type: String
  },
  options: {
    type: Object
  }
})
let myChart = null
onMounted(() => {
  window.addEventListener('resize', () => {
    console.log(myChart)
    myChart.resize()
  })
})
watch(props.options, (val) => {
  myChart = echarts.init(main.value, null, {
    width: props.width,
    height: props.height
  })
  myChart.setOption(props.options);
  console.log(val)
})
</script>